import request from "@/utils/request";

//管理员
export const addQuestion = (questionAddRequest) =>
    request.post('/question/add', questionAddRequest)

export const getQuestionById = (id) =>
    request.get(`/question/get/${id}`)

export const updateQuestion = (question) =>
    request.post('/question/update', question)

export const deleteQuestionById = (id) =>
    request.post(`/question/delete/${id}`)

export const getQuestionAllByAdmin = (questionQueryRequest) =>
    request.post('question/list/page', questionQueryRequest)

//普通用户
export const getQuestionAll = (questionQuery) => {
    const data = {questionQueryRequest: questionQuery}; // 构造请求体数据
    return request.post('question/list/page/vo', data);
}

export const getQuestionByIdUser = (id) =>
    request.get(`/question//get/vo/${id}`)

//提交题目
export const doQuestion = (param) => {
    // const data = {questionSubmitAddRequest:param}
    request.post('/question/addQuestion', param)
}
//获得题目信息
export const getQuestion = (param) => {
    return request.post('/question/getSubmit', param)
}

//运行题目
export const runCode = (runVO) => {
    return request.post('/judge/runCode', runVO)
}

//点赞题目
export const likeQuestion = (questionId, isLike) => {
    return request.put(`/question/like/${questionId}/${isLike}`)
}

//获取点赞状态
export const getLikeState = (questionId) => {
    return request.get(`/question/isLike/${questionId}`,)
}
//获取题目排行榜
export const getQuestionRank = () => {
    return request.get(`/question/list/rank`)
}
